<!--
 * @Author: wuyue
 * @Date: 2023-02-23 11:43:52
 * @LastEditTime: 2023-03-20 10:01:24
 * @LastEditors: wuyue
 * @Descripttion: 计量设备调拨清单
 * @version: 
-->
<template>
  <div>
    <a-card :bordered="false">
      <title-name :title="title"></title-name>
      <b-table ref="table" bordered :columns="columns" :request="tableDataRequest" row-key="index">
        <template v-if="text && text.length" slot="ownPicFileList" slot-scope="text">
          <UploadList
            businessCode="PM44"
            :uploadArrys="[text[0]]"
            :disabled="true"
            :isShow="false"
            uploadType="image"
          >
          </UploadList>
        </template>
      </b-table>
    </a-card>
  </div>
</template>

<script>
import { queryTransferDetailPage } from '@/api/quality/meterageEquipmentAllocate'
import UploadList from '@/components/UploadList'

export default {
  name: "allocateLog",
  components: { UploadList },
  props: {
    title: {
      type: String,
      default() {
        return '计量设备调拨清单'
      }
    },
  },
  data() {
    return {
      previewImage: '',
      previewVisible: false,
      columns: [
        {
          title: '序号',
          dataIndex: 'serial',
          width: 70,
          customRender: (text, row , index) => index+1
        },
        {
            title: '设备编号',
            dataIndex: 'mdCode'
        },
        {
            title: '设备名称',
            dataIndex: 'mdName'
        },
        {
            title: '规格型号',
            dataIndex: 'specificationModel'
        },
        {
            title: '设备图片',
            dataIndex: 'ownPicFileList',
            scopedSlots: { customRender: 'ownPicFileList' },
            width: 150
        },
        {
            title: '备注',
            dataIndex: 'remarks',
            ellipsis: true
        },
        {
            title: '调出单位',
            dataIndex: 'transferOutUnitName'
        },
        {
            title: '调拨状态',
            dataIndex: 'mdTransferStateName'
        },
        {
            title: '调出情况说明',
            dataIndex: 'transferOutCondition'
        },
        {
            title: '调入情况说明',
            dataIndex: 'transferInCondition'
        },
      ],
      tableDataRequest: async (params) => {
          let { pageNo, pageSize } = params;
          let query = {
            pageNum: pageNo,
            pageSize,
            param: {
              transferId: this.$route.query.id
            }
          };
          return queryTransferDetailPage(query).then((res) => {
          if (res.code === '0') {
            return { code: 200, data: res.data?.list, totalSize: res.data?.total }
          }
        })
      },
    }
  },
  methods: {
    // 预览
    preview(file) {
      this.previewImage = file.url || this.$fileUrl(file)
      this.previewVisible = true
    },
  }
}
</script>